﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Hangjing.Model;
using Hangjing.SQLServerDAL;

using System.Text;
using System.Text.RegularExpressions;
using Hangjing.SQLServerDAL.serverinterface;
// CopyRight (c) 2009-2012 HangJing Teconology. All Rights Reserved.
// zjf@ihangjing.com
// 2012-02-13

public partial class AndroidAPI_shop_Login : System.Web.UI.Page
{
    //APP/Android/Login.aspx?username=test&password=123456
    //返回 state：1 正常登录 -1 登录失败 0 账号不存在
    //{"userid":"1","state":"1","name":"配送员1号"}

    ShopAPP dal = new ShopAPP();

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();

        string userid = "0";
        string state = "-1";

        //输入参数：用户名、密码
        string username = WebUtility.InputText(Request["username"]);
        string password = WebUtility.GetMd5(WebUtility.InputText(Request["password"]));

        PointsInfo model = new PointsInfo();

        string rs = "{\"userid\":\"" + 0 + "\",\"state\":\"" + 0 + "\"}";

        string sessionid = "ios-"+ System.Guid.NewGuid().ToString();

        int shopid = dal.APPLogin(username, password, sessionid);

        if (shopid > 0)
        {
            userid = shopid+"";
            state = "1";
            rs = dal.getLoginJSON(shopid, "1").Replace("Login::","");
        }

        Response.Write(rs);
        Response.End();
    }
}
